package com.cloud.controller;

import com.cloud.util.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cloud.service.TaskService;

@Controller
@RequestMapping("/task")
public class TaskController {
	
	@Autowired
	private TaskService taskService;
	
	private static Logger log = LoggerFactory.getLogger(TaskController.class);
	
	@GetMapping("/list")
	public String list() {
		return "task";
	}
	//执行任务
	@ResponseBody
	@PostMapping("/execute")
	public R execute(String platform, String type, String code, String num) {
		log.info("发布任务: {}-{}-{}-{}",platform,type,code,num);
		R result = taskService.newTask(platform,type,code,num);
		return result;
	}
	//实时刷新任务列表
	@ResponseBody
	@GetMapping("/flush")
	public R flushTask() {
		R result = taskService.flush();
		return result;
	}
	
	//客户端返回执行结果
	@RequestMapping("/result")
	public void result() {
		
	}
}
